/*<summary>
Created By : Preeti
Created On : 9/20/2008
Class Name : PatientBilling_Mapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Utils;

namespace InPatientCntroller
{
    public class PatientBilling_Mapper
    {
        public bool Load_PatientBilling_DATA(string ID, PatientBilling objPatientBilling)
        {
            if (!(objPatientBilling == null))
            {
                ezUtilsAdapter DBL = new ezUtilsAdapter();
                int ResultVal;
                bool bresult;
                string CRNumber;
                string RcptNumber;
                string ChargeType;
                double Quantity;
                double Rate;
                double Amount;
                double AmountPaid;
                string DiscountType;
                string RecomandedBy;

                CRNumber = objPatientBilling.CRNumber;
                RcptNumber = objPatientBilling.RcptNumber;
                ChargeType = objPatientBilling.ChargeType;
                Quantity = objPatientBilling.Quantity;
                Rate = objPatientBilling.Rate;
                Amount = objPatientBilling.Amount;
                AmountPaid = objPatientBilling.AmountPaid;
                DiscountType = objPatientBilling.DiscountType;
                RecomandedBy = objPatientBilling.RecomandedBy;

                try
                {
                    ResultVal = DBL.RunSPReturnInteger("SP_SetPatientBilling",
                    new SqlParameter("@vchID", ID),
                   new SqlParameter("@vchCRNumber", CRNumber),
                     new SqlParameter("@vchRcptNumber", RcptNumber),
                     new SqlParameter("@vchChargeType", ChargeType),
                     new SqlParameter("@fltQuantity", Quantity),
                     new SqlParameter("@fltRate", Rate),
                     new SqlParameter("@fltAmount", Amount),
                     new SqlParameter("@fltAmountPaid", AmountPaid),
                     new SqlParameter("@vchDiscountType", DiscountType),
                     new SqlParameter("@vchRecomandedBy", RecomandedBy));
                    if (ResultVal == 0) { bresult = true; } else { bresult = false; } return bresult;
                }
                catch (SqlException ex)
                {
                    string errorMessage = string.Format(
                        "An Error Occurred While Loading the PatientBilling Information to the DB. Message: {0}", ex.Message);
                    //throw new MappingException(errorMessage, ex);}
                    return false;
                }
                finally
                {
                    DBL.Dispose();
                }
            }

            else { return false; }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }
    }
}